﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.Configuration.VWebConfigManagerPage" %>

<script runat="server">
	protected void TrustLevelGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
	{
		TrustLevelDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
	}

	protected void TrustLevelDetailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
	{
		ShowAlert_DetailsView_ItemInserted(e);

		TrustLevelGridView.SelectedIndex = -1;
		TrustLevelGridView.DataBind();
	}

	protected void TrustLevelDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);

		TrustLevelGridView.SelectedIndex = -1;
		TrustLevelGridView.DataBind();
	}

	protected void TrustLevelDetailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
	{
		ShowAlert_DetailsView_ItemDeleted(e);

		TrustLevelDetailsView.ChangeMode(DetailsViewMode.Insert);

		TrustLevelGridView.SelectedIndex = -1;
		TrustLevelGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>SecurityPolicy</h2>

	<div>
		<asp:ObjectDataSource ID="TrustLevelDetailsViewDataSource" runat="server" 
			DeleteMethod="RemoveTrustLevel" InsertMethod="AddTrustLevel" 
			SelectMethod="GetTrustLevel" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.SecurityPolicySectionManager" 
			UpdateMethod="ModifyTrustLevel">
			<DeleteParameters>
				<asp:Parameter Name="name" Type="String" />
			</DeleteParameters>
			<UpdateParameters>
				<asp:Parameter Name="name" Type="String" />
				<asp:Parameter Name="policyFile" Type="String" />
			</UpdateParameters>
			<SelectParameters>
				<asp:ControlParameter ControlID="TrustLevelGridView" Name="name" 
					PropertyName="SelectedValue" Type="String" />
			</SelectParameters>
			<InsertParameters>
				<asp:Parameter Name="name" Type="String" />
				<asp:Parameter Name="policyFile" Type="String" />
			</InsertParameters>
		</asp:ObjectDataSource>
		<asp:ObjectDataSource ID="TrustLevelGridViewDataSource" runat="server" 
			SelectMethod="GetTrustLevelCollection" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.SecurityPolicySectionManager"></asp:ObjectDataSource>
		<fieldset>
			<legend>trustLevel</legend>
			<asp:DetailsView ID="TrustLevelDetailsView" runat="server" 
				AutoGenerateRows="False" CellPadding="5" DataKeyNames="Name" 
				DataSourceID="TrustLevelDetailsViewDataSource" DefaultMode="Insert" 
				oniteminserted="TrustLevelDetailsView_ItemInserted" 
				onitemupdated="TrustLevelDetailsView_ItemUpdated" 
				onitemdeleted="TrustLevelDetailsView_ItemDeleted">
				<Fields>
					<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" 
						SortExpression="Name" />
					<asp:BoundField DataField="PolicyFile" HeaderText="PolicyFile" 
						SortExpression="PolicyFile" />
					<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
						ShowInsertButton="True" ButtonType="Button" />
				</Fields>
			</asp:DetailsView>
			<asp:GridView ID="TrustLevelGridView" runat="server" 
				AutoGenerateColumns="False" CellPadding="5" DataKeyNames="Name" 
				DataSourceID="TrustLevelGridViewDataSource" 
				onselectedindexchanging="TrustLevelGridView_SelectedIndexChanging">
				<Columns>
					<asp:CommandField ShowSelectButton="True" />
					<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
					<asp:BoundField DataField="PolicyFile" HeaderText="PolicyFile" 
						SortExpression="PolicyFile" />
				</Columns>
				<SelectedRowStyle BackColor="SkyBlue" />
			</asp:GridView>
		</fieldset>
	</div>
</asp:Content>